package com.dacd.tcgandroid.dialog

import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface

class DialogFactory {

    companion object {
        /**
         * dismissing dialog for res
         */
        fun showDismissDialog(context: Context, content: String, btn: Int) {
            AlertDialog.Builder(context)
                .setMessage(content)
                .setPositiveButton(btn, DialogInterface.OnClickListener { dialog: DialogInterface?, _: Int ->
                    dialog!!.dismiss()
                }).create().show()
        }

        fun showAskDialog(
            context: Context, content: String, btnOk: Int, btnCancel: Int
            , listener: DialogInterface.OnClickListener) {
            AlertDialog.Builder(context)
                .setMessage(content)
                .setPositiveButton(btnOk, listener)
                .setNegativeButton(btnCancel, DialogInterface.OnClickListener { dialog: DialogInterface?, _: Int ->
                    dialog!!.dismiss()
                }).create().show()
        }

        fun showAskDialogForUpdate(
            context: Context, content: String, btnOk: Int, listener: DialogInterface.OnClickListener) {
            AlertDialog.Builder(context)
                .setMessage(content)
                .setCancelable(false)
                .setPositiveButton(btnOk, listener)
                .create().show()
        }

        /**
         * 自定点击事件的单按钮弹窗
         */
        fun showDismissDialogCustomerClick(context: Context, content: String, btn: Int
                                          , listener: DialogInterface.OnClickListener) {
            AlertDialog.Builder(context)
                .setMessage(content)
                .setPositiveButton(btn, listener).create().show()
        }
    }


}